<template>
  <div>
    <div>
      <h3>部署拍卖合约( 部署前请先去 账户管理-解锁账户取得私钥 )</h3>
      <el-input style="width: 800px" placeholder="请输入私钥" v-model="paiMaiDeploy.privateKey">
        <template slot="prepend">私钥：</template>
      </el-input><br><br>
      <el-input style="width: 800px" placeholder="请输入卖家收款地址" v-model="paiMaiDeploy._beneficiary">
        <template slot="prepend">收款地址：</template>
      </el-input><br><br>
      <el-input style="width: 400px" placeholder="请输入拍卖持续时间" v-model="paiMaiDeploy._biddingTime">
        <template slot="prepend">拍卖持续时间(秒)：</template>
      </el-input>
      <el-input style="width: 400px" placeholder="请输入gasLimit，建议50万以上" v-model="paiMaiDeploy.gasLimit">
        <template slot="prepend">gasLimit：</template>
      </el-input>
      <br><br>
      <el-input style="width: 400px" placeholder="请输入拍卖名称" v-model="paiMaiDeploy.id">
        <template slot="prepend">拍卖名称：</template>
      </el-input>
      <el-button type="primary" @click="newPaiMaiContract">提交部署合约</el-button>
      <div>
        <el-descriptions column=1 title="部署结果">
          <el-descriptions-item label="message">{{paiMaiContractInfo.message}}</el-descriptions-item>
          <el-descriptions-item label="合约地址">{{paiMaiContractInfo.contractAddress}}</el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "newContract",
  data() {
    return {
      paiMaiDeploy: {
        privateKey: '',
        _beneficiary: '',
        _biddingTime: '',
        gasLimit: '',
        id: '',
      },
      paiMaiContractInfo: '',
    }
  },

  methods: {
    newPaiMaiContract() {
      this.axios.post("/newPaiMaiContract", {
        privateKey: this.paiMaiDeploy.privateKey,
        _beneficiary: this.paiMaiDeploy._beneficiary,
        _biddingTime: this.paiMaiDeploy._biddingTime,
        gasLimit: this.paiMaiDeploy.gasLimit,
        id: this.paiMaiDeploy.id,
      }).then(res => {
        if (res.data.code == 200) {
          this.paiMaiContractInfo = res.data;
        }else {
          alert(res.data.message);
        }
      })
    },
  },
}
</script>

<style scoped>

</style>
